var auth = require('../middlewares/auth');

module.exports = function(app){
  app.get('/login', require('./site').login);
  app.get('/register', require('./site').register);
  app.get('/active_account/:username', auth.authAdmin, require('./site').activeAccount);  //帐号激活
  app.get('/notify/:cate', require('./notify'));
  app.get('/group', require('./site').group);

  app.post('/register', require('./user').register);
  app.post('/login', require('./user').login);
  app.get('/logout', require('./user').logout);
  app.get('/user/:username', require('./user').getProfile);
  app.all('/profile/edit', auth.userRequired, require('./user').editProfile);
  app.post('/achievement', auth.userRequired, require('./user').addAchievement);
  app.delete('/achievement', auth.userRequired, require('./user').deleteAchievement);

  app.get('/', require('./index').index);
  app.get('/datasets', require('./index').datasets);

  app.get('/search', require('./search').search);

  //获取,新建,删除
  app.get('/dataset/:dsid', require('./dataset').getDataset);
  app.get('/new/cheatsheet', auth.userRequired,  require('./dataset').newDataset);
  app.post('/dataset', auth.userRequired,  require('./dataset').postDataset);

  app.get('/edit/dataset/:dsid', auth.userRequired, auth.authAdmin, require('./dataset').editDataset);
  app.put('/dataset',auth.userRequired, auth.authAdmin, require('./dataset').putDataset);
  app.delete('/dataset', auth.userRequired, auth.authAdmin, require('./dataset').deleteDataset);

  //comment
  app.post('/comment', auth.userRequired, require('./dataset').addComment);

  //新建一个showcase
  app.post('/showcase', require('./showcase').createShowcase)
  //把某个cheatsheets加入某个showcase
  app.post('/showcase/:showcasename', require('./showcase').addCheat2Case)
  //把某个cheatsheets移除出showcase
  app.delete('/showcase/:showcasename', require('./showcase').removeCheatFromCase)
}
